/**
 * @param {number} n
 * @return {boolean}
 */
var isPowerOfThree = function(n) {
  let num = 0
  while (n >= num) {
    if (n == Math.pow(3, num)) return true
    num++
  }
  return false
}

console.log(isPowerOfThree(27))
